import { fetch } from '@/little/fetch';
import md5 from 'crypto-js/md5';
export const getConfByCode = (code) => fetch.get(`/v1/config/getByCode/${code}`);
export const getDictByCode = (code) => fetch.get(`/v1/dict/getByCode/${code}`);
export const getDirectionByDriving = (args) => fetch.get(`/v1/tencent/map/directionByDriving`, args);

export const upload = (file, name = 'file', hash) =>
    new Promise((resolve, reject) => {
        fetch.upload({
            // url: '/v1/upload/image',
			url:'common/upload' ,
            formData: { isChunk: false, hash: hash ? hash : md5(file).toString() },
            name,
            filePath: file,
            success: (res) => {
				console.log(JSON.parse(res.data).data.fullurl,'JSON.parse(res.data)')
                resolve({ ...res, data: JSON.parse(res.data).data.fullurl });
            },
            fail: (err) => reject(err)
        });
    });
